<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户管理</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>营销管理</li>
    <li>订购单审核管理</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form th:action="@{/orderExamine/queryfenye}" method="post" id="orderFrom">
    <ul class="tools">
      <li> 订单编号:
        <input name="orderid" th:value="${orderid==null?'':orderid}" type="text" />
      </li>
      <li> 客户姓名:
        <input name="customname" th:value="${customname==null?'':customname}" type="text" />
      </li>
      <li> 订购时间:
        <input name="startDate" class="startDate" th:value="${startDate==null?'':startDate}" type="text"  />-<input name="endDate" class="endDate" th:value="${endDate==null?'':endDate}" type="text" />
      </li>
      <li> 金额:
        <input type="text" id="minPrice" th:value="${minPrice==null?'':minPrice}" name="minPrice" class="stinput" />-<input type="text" th:value="${maxPrice==null?'':maxPrice}" id="maxPrice" name="maxPrice" class="stinput" />
      </li>
      <li class="subBut" onclick="chaxun(1)"><img th:src="@{/images/t06.png}" />查询</li>
      <li class="subBut" ><a th:href="@{/order/toAdd}"><img th:src="@{/images/t01.png}" />添加</a></li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>订单编号</th>
          <th>客户姓名</th>
          <th>联系电话</th>
          <th>订购时间</th>
          <th>金额</th>
          <th>操作人</th>
          <th>审核状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr th:each="order:${session.orderPage.data}">
          <td th:text="${orderStat.count + (session.orderPage.pageNum - 1)*session.orderPage.pageSize }">1</td>
          <td th:text="${order.orderid}">DJ201701270001</td>
          <td th:text="${order.custom==null?'':order.custom.customname}">王金平</td>
          <td th:text="${order.custom==null?'':order.custom.telephone}">17370899727</td>
          <td th:text="${order.ordertime==null?'':#dates.format(order.ordertime,'yyyy-MM-dd HH:mm:ss')}">2017-01-25 15:05:05</td>
          <td><span th:with="num=1000" >￥[[${#numbers.formatInteger(order.ordermoney,1,'COMMA')}]]</span></td>
          <td th:text="${order.operatorUser==null?'':order.operatorUser.uname}">关羽</td>
          <td th:text="${order.status}">未审核</td>
          <td>
            <a th:href="@{'/orderExamine/tocheck?orderid='+${order.orderid}}" class="tablelink">审核</a>
          </td>
        </tr>
      </tbody>
    </table>
    <div class="pagin">
      <input type="hidden" name="pageSize" th:value="${session.orderPage.pageSize}" />
      <input type="hidden" name="pageNum" id="pageNum"  th:value="${session.orderPage.pageNum}" />
      <div class="message">共<i class="blue" th:text="${session.orderPage.totalRows}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${session.orderPage.pageNum}" >2&nbsp;</i>页</div>
      <!--总页数大于7页的时候-->
      <ul class="paginList" th:if="${session.orderPage.totalPage>7}">
        <li class="paginItem"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.pageNum==1?1:session.orderPage.pageNum-1}]])"><span class="pagepre"></span></a></li>
        <!--第一个格子-->
        <li th:class="${session.orderPage.pageNum==1?'paginItem current':'paginItem'}">
          <a href="javascript:;"  onclick="lunbo(1)">1</a>
        </li>

        <!--第二个格子-->
        <li class="paginItem" th:if="${(session.orderPage.pageNum>session.orderPage.totalPage-5) && (session.orderPage.pageNum>5)}"><a href="javascript:;">...</a></li>
        <li th:class="${session.orderPage.pageNum==2?'paginItem current':'paginItem'}" th:if="${(session.orderPage.pageNum<=5) || (session.orderPage.pageNum<=session.orderPage.totalPage-5 && session.orderPage.pageNum>5)}">
          <a href="javascript:;" onclick="lunbo(2)">2</a>
        </li>

        <!--第三个格子-->
        <li class="paginItem" th:if="${5<session.orderPage.pageNum && session.orderPage.pageNum<=(session.orderPage.totalPage-5)}"><a href="javascript:;" >...</a></li>
        <li th:class="${session.orderPage.pageNum==3?'paginItem current':'paginItem'}" th:if="${session.orderPage.pageNum<=5}"><a href="javascript:;" onclick="lunbo(3)">3</a></li>
        <li th:class="${session.orderPage.pageNum==(session.orderPage.totalPage-4)?'paginItem current':'paginItem'}" th:if="${(session.orderPage.pageNum>session.orderPage.totalPage-5) && (session.orderPage.pageNum>5)}"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.totalPage-4}]])" th:text="${session.orderPage.totalPage-4}" >6</a></li>

        <!--第四个格子-->
        <li th:class="${session.orderPage.pageNum==4?'paginItem current':'paginItem'}" th:if="${session.orderPage.pageNum<=5}"><a href="javascript:;" onclick="lunbo(4)">4</a></li>
        <li class="paginItem current" th:if="${5<session.orderPage.pageNum && session.orderPage.pageNum<=(session.orderPage.totalPage-5)}" ><a href="javascript:;" th:text="${session.orderPage.pageNum}"></a></li>
        <li th:class="${session.orderPage.pageNum==(session.orderPage.totalPage-3)?'paginItem current':'paginItem'}" th:if="${(session.orderPage.pageNum>session.orderPage.totalPage-5) && (session.orderPage.pageNum>5)}" ><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.totalPage-3}]])" th:text="${session.orderPage.totalPage-3}">7</a></li>
        <!--第五个格子-->
        <li th:class="${session.orderPage.pageNum==5?'paginItem current':'paginItem'}" th:if="${session.orderPage.pageNum<=5}" ><a href="javascript:;" onclick="lunbo(5)">5</a></li>
        <li class="paginItem" th:if="${5<session.orderPage.pageNum && session.orderPage.pageNum<=(session.orderPage.totalPage-5)}"><a href="javascript:;" >...</a></li>
        <li th:class="${session.orderPage.pageNum==(session.orderPage.totalPage-2)?'paginItem current':'paginItem'}" th:if="${(session.orderPage.pageNum>session.orderPage.totalPage-5) && (session.orderPage.pageNum>5)}"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.totalPage-2}]])" th:text="${session.orderPage.totalPage-2}">4</a></li>
        <!--第六个格子-->
        <li class="paginItem" th:if="${session.orderPage.pageNum<=5}"><a href="javascript:;" >...</a></li>
        <li th:class="${session.orderPage.pageNum==(session.orderPage.totalPage-1)?'paginItem current':'paginItem'}" th:if="${session.orderPage.pageNum>5}"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.totalPage-1}]])" th:text="${session.orderPage.totalPage-1}">4</a></li>
        <!--第七个格子-->
        <li th:class="${session.orderPage.pageNum==session.orderPage.totalPage?'paginItem current':'paginItem'}"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.totalPage}]])" th:text="${session.orderPage.totalPage}">10</a></li>

        <!--        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>-->
        <li class="paginItem"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.pageNum==session.orderPage.totalPage?session.orderPage.totalPage:session.orderPage.pageNum+1}]])"><span class="pagenxt"></span></a></li>
      </ul>
      <!--总页数小于8页的时候-->
      <ul class="paginList" th:if="${session.orderPage.totalPage<=7}">
        <li class="paginItem"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.pageNum==1?1:session.orderPage.pageNum-1}]])"><span class="pagepre"></span></a></li>

        <li th:each="i:${#numbers.sequence(1,session.orderPage.totalPage)}" th:class="${i==session.orderPage.pageNum?'paginItem current':'paginItem'}">
          <a href="javascript:;" th:text="${i}" th:onclick="lunbo([[${i}]])"></a>
        </li>

        <li class="paginItem"><a href="javascript:;" th:onclick="lunbo([[${session.orderPage.pageNum==session.orderPage.totalPage?session.orderPage.totalPage:session.orderPage.pageNum+1}]])"><span class="pagenxt"></span></a></li>
      </ul>
    </div>
  </form>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
    $('.startDate').blur(function(){
      var startDate = $('.startDate').val();
      if(startDate != null && startDate != "") {
        if (!isDate(startDate)) {
          $('.startDate').val("");
          alert("格式错误，正确格式：2000-01-01");
        }
      }
    })
    $('.endDate').blur(function(){
      var endDate = $('.endDate').val();
      if(endDate != null && endDate != "") {
        if (!isDate(endDate)) {
          $('.endDate').val("");
          alert("格式错误，正确格式：2000-01-01");
        }
      }
    })

    function isDate(str) {
      var dateReg =  /^((([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29))$/;
      return dateReg.test(str);
    }

    $('#minPrice').blur(function(){
      var minPrice = $('#minPrice').val();
      if(minPrice != null && minPrice != ""){
        if(!isMoney(minPrice)){
          $('#minPrice').val("");
          alert("格式错误，正确格式：1000或1000.00");
        }
      }
    })
    $('#maxPrice').blur(function(){
      var maxPrice = $('#maxPrice').val();
      if(maxPrice != null && maxPrice != "") {
        if (!isMoney(maxPrice)) {
          $('#maxPrice').val("");
          alert("格式错误，正确格式：1000或1000.00");

        }
      }
    })

    function isMoney(str) {
      var moneyReg = /(^[1-9]([0-9]+)?(.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9].[0-9]([0-9])?$)/;
      return moneyReg.test(str);
    }


    function chaxun(pageNum){
      $("#pageNum").val(pageNum);
      $("#orderFrom").submit();
    }
    function lunbo(pageNum){
      $("#pageNum").val(pageNum);
      $("#orderFrom").submit();
    }


</script>
</body>
</html>
